clc
clear
clims = [0 6];
while (1)
    close all;
    axis equal;
    S = init_setup;
    %S.nextPiece = 1;
    imagesc(flipud(S.field), clims);
    axis equal;
    pause();
    while (~S.lost)
        action = randi(size(S.legalMoves{S.nextPiece+1},1),1);
        S = makeMoveAction( S, action);
        imagesc(flipud(S.field), clims);
        S.cleared %cleared rows
        axis equal; 
        S.field
        pause();
    end
end
